package com.ulwx.service;

import java.lang.reflect.Method;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import com.ulwx.database.DataBase;
import com.ulwx.database.DbException;


public class ServiceMethodInterceptor implements MethodInterceptor {
	

     public Object intercept(Object object, Method method, Object[] args,
    		    MethodProxy methodProxy ) throws Throwable {
      
    	// System.out.println("aaaaaa");
    	 Object result=null;
        try{
           result= methodProxy.invokeSuper(object, args);
        }catch(DbException e){
        	
        }
         //System.out.println("bbbbbb");
         return result;
     }
     
     public static void main(String[] args) throws DbException{
    	   Enhancer enhancer = new Enhancer();
    	 
           enhancer.setSuperclass(DataBase.class);
           enhancer.setCallback(new ServiceMethodInterceptor());
           Object obs= enhancer.create();
           DataBase aa=(DataBase)obs;
          // aa.connectDb();
//           
//           XMLConfig x=new XMLConfig();
//   		x.setFileName("ss");
       
	}

}
